import {
  Login,
  NotFound,
  NoPermission
} from 'pages/index.js'
import {
  LineChartOutlined,
  UnorderedListOutlined,
  MailOutlined,
  SettingOutlined
} from '@ant-design/icons';
import Loadable from 'react-loadable'
import Loading from 'components/Loading'

//基础路由
const baseRoutes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/404',
    component: NotFound
  },
]

// 权限路由 （admin中的二级路由）
const authRoutes = [
  {
    path: '/admin/noPermission',
    component: NoPermission,
    name: '没有权限',
    meta: {
      isNav: false,
      roles:'*'
    }
  },
  {
    path: '/admin/artAdd',
    component: Loadable({
      loader: () => import('pages/ArtAdd'),
      loading: Loading
    }),
    name: '添加文章',
    meta: {
      isNav: false,
      roles: ['admin','superAdmin','editor']
    }
  },
  {
    path: '/admin/dashBoard',
    component: Loadable({
      loader: () => import('pages/DashBoard'),
      loading: Loading
    }),
    name: '仪表盘',
    icon: LineChartOutlined,
    meta: {
      isNav: true,
      roles: ['admin','superAdmin','editor']
    }
  },
  {
    path: '/admin/artList',
    component: Loadable({
      loader: () => import('pages/ArtList'),
      loading: Loading
    }),
    name: '文章列表',
    icon: UnorderedListOutlined,
    meta: {
      isNav: true,
      roles: ['admin','superAdmin','editor']
    }
  },
  {
    path: '/admin/artEdit/:id',
    component: Loadable({
      loader: () => import('pages/ArtEdit'),
      loading: Loading
    }),
    name: '文章编辑',
    meta: {
      isNav: false,
      roles: ['admin','superAdmin','editor']
    }
  },
  {
    path: '/admin/message',
    component: Loadable({
      loader: () => import('pages/Message'),
      loading: Loading
    }),
    name: '消息中心',
    icon: MailOutlined,
    meta: {
      isNav: true,
      roles: ['admin','superAdmin','editor']
    }
  },
  {
    path: '/admin/setting',
    component: Loadable({
      loader: () => import('pages/Setting'),
      loading: Loading
    }),
    name: '设置',
    icon: SettingOutlined,
    meta: {
      isNav: true,
      roles: ['superAdmin']
    }
  },
]

export {
  baseRoutes,
  authRoutes
}